<?php
namespace app\mini_api\controller;

use think\Loader;
class Video extends Permission
{
    public function _initialize()
    {
        parent::_initialize();

    }

    public function getById()
    {
        # 视频信息
        $map['id'] = $this->input_data['id'];
        $result = db('Video')->where($map)->find();
        $result['createTime'] = date('Y-m-d H:i:s',$result['create_time']);

        # 视频已学习的信息

        $map = [
            'driver_train_id' => $this->input_data['driver_train_id'],
            'video_id' => $this->input_data['id']
        ];
        $dtv = db('DriverTrainVideo')->where($map)->find();

        $result['status'] = '未完成';
        if($dtv['percent'] == 10000) $result['status'] = '已完成';

        $result['last_time_duration'] = $dtv['duration_done'];

        $this->resSuc($result);
    }

}
